package com.restfinder.common.dao;

import java.io.Serializable;
import java.util.List;
import java.util.Map;


import com.restfinder.model.IEntity;

public interface IRepository<T extends IEntity> extends Serializable {

	/**
	 * Saves the entity, must be not-existing in repository
	 * @param entity must implements {@link IEntity}
	 * 
	 */
	public void save(T entity);
	
	/**
	 * Updates the entity, must be existing in repository
	 * @param entity must implements {@link IEntity}
	 * 
	 */
	public void update(T entity);

	/**
	 * Saves the not-existing entity, updates the existing entity 
	 * @param entity must implements {@link IEntity}
	 * 
	 */
	public void saveOrUpdate(T entity);
	
	/**
	 * Deletes entity, that must exists in the repository
	 * @param entity must implements {@link IEntity}
	 * 
	 */
	public void delete(T entity);

	/**
	 * Gets existing entity by ID
	 * @param id
	 * @return {@link IEntity}
	 */
	public T getById(long id);

	/**
	 * 
	 * @return list of {@link IEntity}
	 * @throws Exception
	 */
	public List<T> list();
}
